/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

/**
 *
 * @author pc0129
 */
import java.net.*;
import java.io.*;

public class KnockKnockProtocol {

    private static final int WAITING = 0;
    private static final int SENTKNOCKKNOCK = 1;
    private int state = WAITING;

    public String processInput(String theInput) {
        String theOutput = null;

        if (state == WAITING) {
            theOutput = KKMultiServer.getNewTask();
            state = SENTKNOCKKNOCK;
        } else if (state == SENTKNOCKKNOCK) {
            if (!theInput.equals("null")) {
                String[] inputs = theInput.split(" ");
                for (String f : inputs){
                KKMultiServer.factors.add(f);
                }
                theOutput = "STOP";
            }
           
        }
        return theOutput;
    }
}